<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function largestGoodInteger(num) {
      let a = ''
      for (let i = 0; i < num.length - 2; i++)
        if (num[i] === num[i + 1] && num[i] === num[i + 2])
          a = Math.max(+a, +num[i]).toString()
      return a + a + a
    };
    console.log(largestGoodInteger("6777133339"));
  </script>
</body>

</html>